// demo.groovy
import groovy.sql.Sql

def url = 'jdbc:mysql://localhost:3306/demo?useSSL=false&serverTimezone=UTC'
def user = 'root'
def password = '123.com'
def driver = 'com.mysql.cj.jdbc.Driver'

Sql sql = Sql.newInstance(url, user, password, driver)

// 查询示例
sql.eachRow('SELECT id, name FROM user') { row ->
    println "ID: ${row.id}, Name: ${row.name}"
}
// 假设参数绑定在变量里
println "传入的参数有："

// 遍历所有参数
binding.variables.each { key, value ->
    println "${key} = ${value}"
}

// 如果你只想打印特定参数，比如 name 和 age
if (binding.hasVariable('name') && binding.hasVariable('age')) {
    println "Hello ${name}, you are ${age} years old."
}

def name = 'Guillaume' // a plain string
def greeting = "Hello ${name}"
println greeting

def uri = new URI("https://www.baidu.com")
def url1 = uri.toURL()
def text = url1.text
println text


return  "这是返回的结果"
